<?php

namespace App\Admin\Controllers;

use App\Exceptions\ServiceException;
use App\Exceptions\ServiceExceptionConstant;
use Illuminate\Http\Request;

class EditorUploadController extends BaseController
{

    /**
     * 上传wang editor2 的图片
     * @param Request $request
     * @return array
     */
    public function uploadImgWangEditor2(Request $request)
    {
        if (!$request->file('upload')) {
            throw new ServiceException(ServiceExceptionConstant::getErrorData("upload_failed"));
        }
        $default_disk = config('admin.upload.disk');
        $path         = $request->file('upload')->store('adm_images');
        return config('filesystems.disks.' . $default_disk . '.url') . $path;
    }

}
